import 'package:flutter/material.dart';
import 'package:flutterlib/widgets/pull/nested/pull_load_widget.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_page_widget.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

abstract class BasePullLoadManger{
  final ScrollController scrollController = new ScrollController();

  final GetDataLogic getDataLogic;

  final bool wantKeepAlive;

  final bool enablePullDown;

  final bool enablePullUp;

  final RenderItem renderItem;

  final RenderHeader renderHeader;

  final RenderFooter renderFooter;

  final WidgetBuilder renderEmptyView;

  final bool isSliver;

  RefreshController refreshController;

  List dataList;

  void Function(Function callback) dataSetChange;

  BasePullLoadManger({this.renderEmptyView, this.isSliver : false, @required this.getDataLogic,this.renderItem, this.renderHeader
    , this.renderFooter, this.wantKeepAlive : true
    , this.enablePullDown : true, this.enablePullUp : true});


  void setDataList(List list);

  void setRefreshController(RefreshController controller);


  /**
   * 获取列表数据
   */
  getDataList();

  /**
   * 获取下拉刷新的控制器
   */
  getRefreshController();

  /**
   * 下拉刷新
   */
  void refresh();

  void notifyDataSetChange(Function dataChange);


  /**
   * 获取数量
   */
  getCount();

  /**
   * 获取滚动控制器
   */
  getController();


  /**
   * 添加滚动监听
   */
  void addScrollListener(Function listener);

  /**
   * 获取列表项
   */
  getListItem(int i);

  /**
   * 跳到具体的位置，需要自己计算高度位置
   */
  scrollToPosition(double position);

  /**
   * 跳到具体的位置，需要自己计算高度位置,有动画
   */
  animaScrollToPosition(double position, Duration duration, Curve curve);

  /**
   * 跳到指定的key位置
   */
  ensureVisiable(GlobalKey key);

  void setNotifyCallBack(void Function(Function callback) notifyDataSetChange);

}